package cn.glutnn.subject.common.enums;

import lombok.Getter;

/**
 * Author:   msh
 * Date:     2024/11/21 下午2:24
 * Description:
 */

@Getter
public enum ResultCodeEnum {
    SUCCESS(200, "成功"),
    FAILED(500, "失败");

    private Integer code;
    private String desc;

    ResultCodeEnum(Integer code, String message) {
        this.code = code;
        this.desc = message;
    }

    /**
     * 根据code值获取枚举
     *
     * @param codeValue code值
     * @return
     */
    public static ResultCodeEnum getByCode(int codeValue) {
        for (ResultCodeEnum resultCodeEnum : ResultCodeEnum.values()) {
            if (resultCodeEnum.code == codeValue) {
                return resultCodeEnum;
            }
        }
        return null;
    }
}
